package com.example.springbootwebserviceproxy.util;

import com.example.springbootwebserviceproxy.model.SOAPServiceProxyDefinition;
import com.example.springbootwebserviceproxy.model.WebServiceBeanDefinition;

/**
 * AOSPDefinitionBuilderUtil.
 *
 * @author <a href='mailto:likeguo@apache.com'> likeguo </a>
 */
public final class AOSPDefinitionBuilderUtil {
    
    private AOSPDefinitionBuilderUtil() {
    }
    
    /**
     * build
     *
     * @param proxyDefinition proxy
     * @return service defainiton
     */
    public static WebServiceBeanDefinition build(final SOAPServiceProxyDefinition proxyDefinition) {
        return WebServiceBeanDefinition.builder()
                .proxyUrl(proxyDefinition.getProtocol() + "://localhost/" + proxyDefinition.getProxyUri())
                .targetUrl(proxyDefinition.getProtocol() + "://" + proxyDefinition.getHost() + "/" + proxyDefinition.getTargetUri())
                .proxyDefinition(proxyDefinition)
                .build();
    }
}
